package com.firewolf.wx.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.firewolf.wx.entities.CommonCategory;
import com.firewolf.wx.entities.CommonGoods;
import com.firewolf.wx.entities.LunBo;
import com.firewolf.wx.entities.Renwu;
import com.firewolf.wx.entities.Tuijian;
import com.firewolf.wx.entities.Xuanyou;
import com.firewolf.wx.service.HomeService;

/**
 * 主页面控制器
 * 
 * @author liuxing
 *
 */
@Controller
@RequestMapping("/home")
public class HomeController {

	@Autowired
	private HomeService homeService;

	/**
	 * 获取轮播图图片
	 * 
	 * @return
	 * 
	 */
	@RequestMapping("/lunbo")
	@ResponseBody
	public List<LunBo> lunbo() {
		return homeService.lunboList();
	}

	/**
	 * 推荐商品信息
	 * 
	 * @return
	 */
	@RequestMapping("/tuijian")
	@ResponseBody
	public List<Tuijian> tuijian() {
		return homeService.tuijianList();
	}

	/**
	 * 查询今日任务
	 * 
	 * @return
	 */
	@RequestMapping("/renwu")
	@ResponseBody
	public List<Renwu> renwu() {
		return homeService.renwuList();
	}

	/**
	 * 选优商品
	 * 
	 * @return
	 */
	@RequestMapping("/xuanyou")
	@ResponseBody
	public List<Xuanyou> xuanyou() {
		return homeService.xuanyou();
	}

	/**
	 * 查询常见推荐商品分类
	 * 
	 * @return
	 */
	@RequestMapping("/commoncategory")
	@ResponseBody
	public List<CommonCategory> commoncategory() {
		return homeService.commoncategory();
	}

	/**
	 * 
	 * @param pageIndex
	 * @param pageSize
	 * @param categoryId
	 *            分类ID
	 * @return
	 */
	@RequestMapping("/commongoods")
	@ResponseBody
	public List<CommonGoods> commongoods(
			@RequestParam(value = "index", defaultValue = "1", required = false) Integer pageIndex,
			@RequestParam(value = "size", defaultValue = "4", required = false) Integer pageSize, Integer categoryId) {
		return homeService.commongoods(pageIndex, pageSize, categoryId);
	}
}
